README
DATE: November 30, 2020

This archive includes the data and code required to replicate the results from Christensen, Hartman, and Samii, "Legibility and External Investment: An Institutional Natural Experiment in Liberia," which is forthcoming at International Organization.

# _______________________________________________________________
CITATION:

@article{christensen:2020le,
    author = {Christensen, Darin and Hartman, Alexandra and Samii, Cyrus},
    title = {Legibility and External Investment: An Institutional Natural Experiment in Liberia},
    journal = {International Organization},
    year = {n.d.}
}

# _______________________________________________________________
INSTRUCTIONS:

All file paths are defined relative to the folder that contains the .rproj file. The easiest way to replicate the results is to open the .rproj file and run the code in _run-all.R. This sources the scripts saved in the code/ folder, and these scripts save results to the figures/ and tables/ folders as appropriate. The code/ directly contains separate, self-contained scripts for every figure and table in the manuscript and supplementary materials. 

To view the output, compile the tex/results.tex file. This will generate a PDF with the figures and tables. Note: we have manually edited the format of some tables in the published version, and those manual edits may not be reflected in the replicated tables. 

# _______________________________________________________________
SYSTEM REQUIREMENTS AND PACKAGES:

* Mac OS X 10.13 or later,
* R 4.0.2+
* `ggplot` package installed (to set `theme()` options in _premable.R)

The code relies on a number of other R packages. We list those packages in the code/helper-scripts/_preamble.R script. To install all of these packages, run `source("code/_helper-scripts/_preamble.R")` and then `Preamble(install = TRUE)`.

Note: the `lfe` package was removed from CRAN on 4 Dec. 2020. If it has not been restored when you attempt to run this replication archive, you will have to install an archived version of the package.

# _______________________________________________________________
CONLEY STANDARD ERRORS:

We report Conley standard errors in Table 1 and Table A7. There are two things to note about this analysis: (1) you need to compile the C++ code using Rcpp, which may require additional system configuation; (2) this code requires a lot of memory, as it requires the construction of very large distance matrices. If a table includes Conley standard errors, the associated script will include a line that reads `compute_conley <- FALSE` near the top (as in code/table-1.R). You'll need to change this flag to TRUE; in code/table-a7.R, you'll also need to re-run lines 51-60 for models 2-5.

# _______________________________________________________________
DATA CATALOG:

We provide the data as .rds files. These files are frequently lists of related shapefiles and/or tabular data. 

* adm-boundaries.rds: list of three shapefiles containing the following
[[adm0]]: country boundary
[[adm1]]: county boundaries
[[adm2]]: district boundaries
[[adm3]]: clan boundaries

* afrobarometer.rds: list of three datatables containing the following:
[[r4]]: geo-coded round 4 Afrobarometer data from Liberia
[[r5]]: geo-coded round 5 Afrobarometer data from Liberia
[[r6]]: geo-coded round 6 Afrobarometer data from Liberia

* agroclimatic.rds: datatable including variables from Worldclim on altitude in meters (alt), average annual precipitation in millimeters (prec), and average annual temperature in Celsius * 10 (temp).

* census-2008.rds: list of two datatables containing the following:
[[raw]]: locality-level data from the 2008 census
[[merged]]: spatial merge of our panel (gfc/panel.rds) with the census data

* commodity-prices.rds: datatable containing commodity price indices for rubber and palm (from the IMF), as well as the FAOs baskets (meat, dairy, etc.). Prices are rebased to 2001.

* concession-boundaries.rds: shapefile of commercial concession boundaries

* gfc/origional-resolution.rds: datatable with cross-sectional Global Forest Change data at the original resolution. Data is limited to cells within 40km of the institutional boundary.

* gfc/panel.rds: datatable with main panel (grid cell-year)

* institutional-boundary.rds: list of four shapefiles containing the following:
[[`40mi`]]: line demarcating institutional boundary 40 miles from coast
[[`1853`]]: line demarcating inland extent of land purchases in 1853
[[`40km buffer]]: polygon that represents a 40-kilometer buffer around the 40-mile institutional boundary
[[Hinterland]]: polygon that represents the Hinterland-side of the 40-mile institutional boundary

* land-matrix.rds: datatable with continent-year panel of deals from the Land Matrix

* market-access.rds: datatable with cross-sectional data at the grid cell-level on the average distance to ports (avg_dist_port), distance to the closest primary road (avg_dist_rd), and distance to monrovia (avg_dist_monrovia).

* placebo.rds: list containing the following: 
[[county]]: datatable with cross-sectional data from Global Forest Change for placebo test on County-side of boundary
[[hinterland]]: datatable with cross-sectional data from Global Forest Change for placebo test on Hinterland-side of boundary
[[`Polygon: County Placebo`]]: shapefile of polygon for placebo area on County-side of institutional boundary
[[`Polygon: County Control`]]: shapefile of polygon for control area on County-side of institutional boundary
[[`Polygon: Hinterland Placebo`]]: shapefile of polygon for placebo area on Hinterland-side of institutional boundary
[[`Polygon: Hinterland Control`]]: shapefile of polygon for control area on Hinterland-side of institutional boundary

The sources and construction of these data are described in the text. 

# _______________________________________________________________
SESSION INFO:

R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.7

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets  methods  
[8] base     

other attached packages:
 [1] data.table_1.13.0         haven_2.3.1              
 [3] forcats_0.5.0             stringr_1.4.0            
 [5] dplyr_1.0.2               purrr_0.3.4              
 [7] readr_1.3.1               tidyr_1.1.2              
 [9] tibble_3.0.3              tidyverse_1.3.0          
[11] sf_0.9-6                  modelsummary_0.6.2       
[13] stargazer_5.2.2           raster_3.3-13            
[15] sp_1.4-2                  lubridate_1.7.9          
[17] RcppArmadillo_0.9.900.3.0 Rcpp_1.0.5               
[19] lfe_2.8-5.1               Matrix_1.2-18            
[21] extrafont_0.17            egg_0.4.5                
[23] ggplot2_3.3.2             gridExtra_2.3            
[25] scales_1.1.1             

loaded via a namespace (and not attached):
 [1] httr_1.4.2         jsonlite_1.7.1     modelr_0.1.8      
 [4] Formula_1.2-3      assertthat_0.2.1   blob_1.2.1        
 [7] tables_0.9.6       cellranger_1.1.0   Rttf2pt1_1.3.8    
[10] pillar_1.4.6       backports_1.1.10   lattice_0.20-41   
[13] glue_1.4.2         extrafontdb_1.0    digest_0.6.25     
[16] rvest_0.3.6        colorspace_1.4-1   sandwich_3.0-0    
[19] htmltools_0.5.0    pkgconfig_2.0.3    broom_0.7.1       
[22] xtable_1.8-4       generics_0.0.2     ellipsis_0.3.1    
[25] withr_2.3.0        cli_2.0.2          magrittr_1.5      
[28] crayon_1.3.4       readxl_1.3.1       fansi_0.4.1       
[31] fs_1.5.0           xml2_1.3.2         class_7.3-17      
[34] tools_4.0.2        hms_0.5.3          lifecycle_0.2.0   
[37] munsell_0.5.0      reprex_0.3.0       compiler_4.0.2    
[40] e1071_1.7-3        rlang_0.4.7        classInt_0.4-3    
[43] units_0.6-7        rstudioapi_0.11    gtable_0.3.0      
[46] codetools_0.2-16   DBI_1.1.0          R6_2.4.1          
[49] zoo_1.8-8          knitr_1.30         KernSmooth_2.23-17
[52] stringi_1.5.3      parallel_4.0.2     vctrs_0.3.4       
[55] dbplyr_1.4.4       tidyselect_1.1.0   xfun_0.18 
